home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Apple Macintosh Developer Technical Support
- **
- ** Routines demonstrating how to play and record sound at the same time.
- **
- ** by Mark Cookson, Apple Developer Technical Support
- **
- ** File: Cheap_Studio.c
- **
- ** Copyright ©1996 Apple Computer, Inc.
- ** All rights reserved.
- **
- ** You may incorporate this sample code into your applications without
- ** restriction, though the sample code has been provided "AS IS" and the
- ** responsibility for its operation is 100% yours. However, what you are
- ** not permitted to do is to redistribute the source as "Apple Sample
- ** Code" after having made changes. If you're going to re-distribute the
- ** source, we require that you make it clear in the source that the code
- ** was descended from Apple Sample Code, but that you've made changes.
- */
-
- #include "SimpleApp_Sound.h"
- #include <SoundInput.h>
- #include <Drag.h>
- #include <Gestalt.h>
-
- typedef struct {
- long sanitycheck;
- SPBPtr recordRec;
- Ptr pb0,
- pb1;
- Ptr recBuffer0,
- recBuffer1;
- Fixed sampleRate;
- OSType compression;
- unsigned long totalBytes;
- long myA5,
- devBuffer,
- soundRefNum;
- short whichBuffer,
- fileRefNum,
- numChannels,
- sampleSize;
- OSErr theErr; //last error returned by SPBRecord or PBWrite
- } Vars, *VarsPtr;
-
- OSErr PrepairToRecordToDisk (VarsPtr myVars);
- OSErr RecordToDisk (VarsPtr);
- OSErr FinishRecording (VarsPtr myVars);
-
- Vars myVars;
-
- /*-----------------------------------------------------------------------*/
- void MyIdleProc (EventRecord *evt)
- /*-----------------------------------------------------------------------*/
- {
- #ifndef __SC__
- #pragma unused (evt)
- #endif
-
- if (sound1Playing && ASoundIsDone (mySoundInfo1) == true) {
- ASoundDonePlaying (mySoundInfo1, nil);
- gSACurControl = playButton1;
- sound1Playing = false;
- SetMyTitle ("\pPlay");
- }
- if (sound2Playing && ASoundIsDone (mySoundInfo2) == true) {
- ASoundDonePlaying (mySoundInfo2, nil);
- gSACurControl = playButton2;
- sound2Playing = false;
- SetMyTitle ("\pPlay");
- }
- if (sound3Playing && ASoundIsDone (mySoundInfo3) == true) {
- ASoundDonePlaying (mySoundInfo3, nil);
- gSACurControl = playButton3;
- sound3Playing = false;
- SetMyTitle ("\pPlay");
- }
- if (sound4Playing && ASoundIsDone (mySoundInfo4) == true) {
- ASoundDonePlaying (mySoundInfo4, nil);
- gSACurControl = playButton4;
- sound4Playing = false;
- SetMyTitle ("\pPlay");
- }
- if (sound5Playing && ASoundIsDone (mySoundInfo5) == true) {
- ASoundDonePlaying (mySoundInfo5, nil);
- gSACurControl = playButton5;
- sound5Playing = false;
- SetMyTitle ("\pPlay");
- }
- if (sound6Playing && ASoundIsDone (mySoundInfo6) == true) {
- ASoundDonePlaying (mySoundInfo6, nil);
- gSACurControl = playButton6;
- sound6Playing = false;
- SetMyTitle ("\pPlay");
- }
- if (playAll == true) {
- if (!sound1Playing && !sound2Playing && !sound3Playing && !sound4Playing && !sound5Playing && !sound6Playing) {
- gSACurControl = playAllButton;
- SetMyTitle ("\pPlay All");
- playAll = false;
- }
- } else {
- if (sound1Playing && sound2Playing && sound3Playing && sound4Playing && sound5Playing && sound6Playing) {
- gSACurControl = playAllButton;
- SetMyTitle ("\pStop All");
- playAll = true;
- }
- }
- }
-
- /*-----------------------------------------------------------------------*/
- OSErr DoPlay1 (void)
- /*-----------------------------------------------------------------------*/
- {
- OSErr theErr;
-
- if (sound1Set == false) {
- theErr = ASoundGetFileToPlay (mySoundInfo1);
- theErr = ASoundReadyForPlaying (mySoundInfo1, nil);
- if (theErr == noErr) {
- sound1Set = true;
- sound1Playing = false;
- SetMyTitle ("\pPlay");
- }
- } else {
- if (sound1Playing == false) {
- if (playAll == true) {
- SndCommand theCmd;
- SndChannelPtr theChan;
-
- theChan = ASoundGetChan (mySoundInfo1);
- theCmd.cmd = syncCmd;
- theCmd.param1 = soundsToSync;
- theCmd.param2 = 'scme';
- theErr = SndDoImmediate (theChan, &theCmd);
- }
- theErr = ASoundPlay (mySoundInfo1);
- if (theErr == noErr) {
- sound1Playing = true;
- gSACurControl = playButton1;
- SetMyTitle ("\pStop");
- }
- } else {
- theErr = ASoundStop (mySoundInfo1);
- }
- }
-
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- OSErr DoPlay2 (void)
- /*-----------------------------------------------------------------------*/
- {
- OSErr theErr;
-
- if (sound2Set == false) {
- theErr = ASoundGetFileToPlay (mySoundInfo2);
- theErr = ASoundReadyForPlaying (mySoundInfo2, nil);
- if (theErr == noErr) {
- sound2Set = true;
- sound2Playing = false;
- SetMyTitle ("\pPlay");
- }
- } else {
- if (sound2Playing == false) {
- if (playAll == true) {
- SndCommand theCmd;
- SndChannelPtr theChan;
-
- theChan = ASoundGetChan (mySoundInfo2);
- theCmd.cmd = syncCmd;
- theCmd.param1 = soundsToSync;
- theCmd.param2 = 'scme';
- theErr = SndDoImmediate (theChan, &theCmd);
- }
- theErr = ASoundPlay (mySoundInfo2);
- if (theErr == noErr) {
- sound2Playing = true;
- gSACurControl = playButton2;
- SetMyTitle ("\pStop");
- }
- } else {
- theErr = ASoundStop (mySoundInfo2);
- }
- }
-
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- OSErr DoPlay3 (void)
- /*-----------------------------------------------------------------------*/
- {
- OSErr theErr;
-
- if (sound3Set == false) {
- theErr = ASoundGetFileToPlay (mySoundInfo3);
- theErr = ASoundReadyForPlaying (mySoundInfo3, nil);
- if (theErr == noErr) {
- sound3Set = true;
- sound3Playing = false;
- SetMyTitle ("\pPlay");
- }
- } else {
- if (sound3Playing == false) {
- if (playAll == true) {
- SndCommand theCmd;
- SndChannelPtr theChan;
-
- theChan = ASoundGetChan (mySoundInfo3);
- theCmd.cmd = syncCmd;
- theCmd.param1 = soundsToSync;
- theCmd.param2 = 'scme';
- theErr = SndDoImmediate (theChan, &theCmd);
- }
- theErr = ASoundPlay (mySoundInfo3);
- if (theErr == noErr) {
- sound3Playing = true;
- gSACurControl = playButton3;
- SetMyTitle ("\pStop");
- }
- } else {
- theErr = ASoundStop (mySoundInfo3);
- }
- }
-
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- OSErr DoPlay4 (void)
- /*-----------------------------------------------------------------------*/
- {
- OSErr theErr;
-
- if (sound4Set == false) {
- theErr = ASoundGetFileToPlay (mySoundInfo4);
- theErr = ASoundReadyForPlaying (mySoundInfo4, nil);
- if (theErr == noErr) {
- sound4Set = true;
- sound4Playing = false;
- SetMyTitle ("\pPlay");
- }
- } else {
- if (sound4Playing == false) {
- if (playAll == true) {
- SndCommand theCmd;
- SndChannelPtr theChan;
-
- theChan = ASoundGetChan (mySoundInfo4);
- theCmd.cmd = syncCmd;
- theCmd.param1 = soundsToSync;
- theCmd.param2 = 'scme';
- theErr = SndDoImmediate (theChan, &theCmd);
- }
- theErr = ASoundPlay (mySoundInfo4);
- if (theErr == noErr) {
- sound4Playing = true;
- gSACurControl = playButton4;
- SetMyTitle ("\pStop");
- }
- } else {
- theErr = ASoundStop (mySoundInfo4);
- }
- }
-
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- OSErr DoPlay5 (void)
- /*-----------------------------------------------------------------------*/
- {
- OSErr theErr;
-
- if (sound5Set == false) {
- theErr = ASoundGetFileToPlay (mySoundInfo5);
- theErr = ASoundReadyForPlaying (mySoundInfo5, nil);
- if (theErr == noErr) {
- sound5Set = true;
- sound5Playing = false;
- SetMyTitle ("\pPlay");
- }
- } else {
- if (sound5Playing == false) {
- if (playAll == true) {
- SndCommand theCmd;
- SndChannelPtr theChan;
-
- theChan = ASoundGetChan (mySoundInfo5);
- theCmd.cmd = syncCmd;
- theCmd.param1 = soundsToSync;
- theCmd.param2 = 'scme';
- theErr = SndDoImmediate (theChan, &theCmd);
- }
- theErr = ASoundPlay (mySoundInfo5);
- if (theErr == noErr) {
- sound5Playing = true;
- gSACurControl = playButton5;
- SetMyTitle ("\pStop");
- }
- } else {
- theErr = ASoundStop (mySoundInfo5);
- }
- }
-
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- OSErr DoPlay6 (void)
- /*-----------------------------------------------------------------------*/
- {
- OSErr theErr;
-
- if (sound6Set == false) {
- theErr = ASoundGetFileToPlay (mySoundInfo6);
- theErr = ASoundReadyForPlaying (mySoundInfo6, nil);
- if (theErr == noErr) {
- sound6Set = true;
- sound6Playing = false;
- SetMyTitle ("\pPlay");
- }
- } else {
- if (sound6Playing == false) {
- if (playAll == true) {
- SndCommand theCmd;
- SndChannelPtr theChan;
-
- theChan = ASoundGetChan (mySoundInfo6);
- theCmd.cmd = syncCmd;
- theCmd.param1 = soundsToSync;
- theCmd.param2 = 'scme';
- theErr = SndDoImmediate (theChan, &theCmd);
- }
- theErr = ASoundPlay (mySoundInfo6);
- if (theErr == noErr) {
- sound6Playing = true;
- gSACurControl = playButton6;
- SetMyTitle ("\pStop");
- }
- } else {
- theErr = ASoundStop (mySoundInfo6);
- }
- }
-
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- OSErr DoPlayAll (void)
- /*-----------------------------------------------------------------------*/
- {
- OSErr theErr;
-
- if (playAll == false) {
- playAll = true;
- soundsToSync = 0;
- if (sound1Set) soundsToSync++;
- if (sound2Set) soundsToSync++;
- if (sound3Set) soundsToSync++;
- if (sound4Set) soundsToSync++;
- if (sound5Set) soundsToSync++;
- if (sound6Set) soundsToSync++;
- if (sound1Set == true && sound1Playing == false) { theErr = DoPlay1 ();soundsToSync--;}
- if (sound2Set == true && sound2Playing == false) { theErr = DoPlay2 ();soundsToSync--;}
- if (sound3Set == true && sound3Playing == false) { theErr = DoPlay3 ();soundsToSync--;}
- if (sound4Set == true && sound4Playing == false) { theErr = DoPlay4 ();soundsToSync--;}
- if (sound5Set == true && sound5Playing == false) { theErr = DoPlay5 ();soundsToSync--;}
- if (sound6Set == true && sound6Playing == false) { theErr = DoPlay6 ();}
- gSACurControl = playAllButton;
- SetMyTitle ("\pStop All");
- } else {
- playAll = false;
- if (sound1Set == true && sound1Playing == true) theErr = DoPlay1 ();
- if (sound2Set == true && sound2Playing == true) theErr = DoPlay2 ();
- if (sound3Set == true && sound3Playing == true) theErr = DoPlay3 ();
- if (sound4Set == true && sound4Playing == true) theErr = DoPlay4 ();
- if (sound5Set == true && sound5Playing == true) theErr = DoPlay5 ();
- if (sound6Set == true && sound6Playing == true) theErr = DoPlay6 ();
- gSACurControl = playAllButton;
- SetMyTitle ("\pPlay All");
- }
-
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- OSErr DoRecord (void)
- /*-----------------------------------------------------------------------*/
- {
- OSErr theErr;
-
- if (!recording) {
- if (!prepairedToRecord) {
- theErr = PrepairToRecordToDisk (&myVars);
- if (theErr == noErr) {
- prepairedToRecord = true;
- gSACurControl = recordButton;
- SetMyTitle ("\pRecord&Play");
- }
- } else {
- DoPlayAll ();
- theErr = RecordToDisk (&myVars);
- recording = true;
- gSACurControl = recordButton;
- SetMyTitle ("\pStop record");
- }
- } else {
- theErr = FinishRecording (&myVars);
- recording = false;
- DoPlayAll ();
- prepairedToRecord = false;
- gSACurControl = recordButton;
- SetMyTitle ("\pSetup Rec");
- }
-
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- OSErr MuteSound1 (void)
- /*-----------------------------------------------------------------------*/
- {
- OSErr theErr;
- unsigned short leftVol, rightVol;
-
- SetControlValue (muteCheck1, !GetControlValue (muteCheck1));
- theErr = ASoundGetVolume (mySoundInfo1, &leftVol, &rightVol);
- if (leftVol != 0 || rightVol != 0) {
- theErr = ASoundSetVolume (mySoundInfo1, 0, 0);
- } else {
- theErr = ASoundSetVolume (mySoundInfo1, 0x100, 0x100);
- }
-
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- OSErr MuteSound2 (void)
- /*-----------------------------------------------------------------------*/
- {
- OSErr theErr;
- unsigned short leftVol, rightVol;
-
- SetControlValue (muteCheck2, !GetControlValue (muteCheck2));
- theErr = ASoundGetVolume (mySoundInfo2, &leftVol, &rightVol);
- if (leftVol != 0 || rightVol != 0) {
- theErr = ASoundSetVolume (mySoundInfo2, 0, 0);
- } else {
- theErr = ASoundSetVolume (mySoundInfo2, 0x100, 0x100);
- }
-
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- OSErr MuteSound3 (void)
- /*-----------------------------------------------------------------------*/
- {
- OSErr theErr;
- unsigned short leftVol, rightVol;
-
- SetControlValue (muteCheck3, !GetControlValue (muteCheck3));
- theErr = ASoundGetVolume (mySoundInfo3, &leftVol, &rightVol);
- if (leftVol != 0 || rightVol != 0) {
- theErr = ASoundSetVolume (mySoundInfo3, 0, 0);
- } else {
- theErr = ASoundSetVolume (mySoundInfo3, 0x100, 0x100);
- }
-
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- OSErr MuteSound4 (void)
- /*-----------------------------------------------------------------------*/
- {
- OSErr theErr;
- unsigned short leftVol, rightVol;
-
- SetControlValue (muteCheck4, !GetControlValue (muteCheck4));
- theErr = ASoundGetVolume (mySoundInfo4, &leftVol, &rightVol);
- if (leftVol != 0 || rightVol != 0) {
- theErr = ASoundSetVolume (mySoundInfo4, 0, 0);
- } else {
- theErr = ASoundSetVolume (mySoundInfo4, 0x100, 0x100);
- }
-
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- OSErr MuteSound5 (void)
- /*-----------------------------------------------------------------------*/
- {
- OSErr theErr;
- unsigned short leftVol, rightVol;
-
- SetControlValue (muteCheck5, !GetControlValue (muteCheck5));
- theErr = ASoundGetVolume (mySoundInfo5, &leftVol, &rightVol);
- if (leftVol != 0 || rightVol != 0) {
- theErr = ASoundSetVolume (mySoundInfo5, 0, 0);
- } else {
- theErr = ASoundSetVolume (mySoundInfo5, 0x100, 0x100);
- }
-
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- OSErr MuteSound6 (void)
- /*-----------------------------------------------------------------------*/
- {
- OSErr theErr;
- unsigned short leftVol, rightVol;
-
- SetControlValue (muteCheck6, !GetControlValue (muteCheck6));
- theErr = ASoundGetVolume (mySoundInfo6, &leftVol, &rightVol);
- if (leftVol != 0 || rightVol != 0) {
- theErr = ASoundSetVolume (mySoundInfo6, 0, 0);
- } else {
- theErr = ASoundSetVolume (mySoundInfo6, 0x100, 0x100);
- }
-
- return theErr;
- }
-
- pascal OSErr ClearAllSounds (long menuResult)
- {
- #pragma unused (menuResult)
- OSErr err;
-
- mySoundInfo1 = ASoundNew (&err);
- mySoundInfo2 = ASoundNew (&err);
- mySoundInfo3 = ASoundNew (&err);
- mySoundInfo4 = ASoundNew (&err);
- mySoundInfo5 = ASoundNew (&err);
- mySoundInfo6 = ASoundNew (&err);
-
- sound1Set = false;
- sound2Set = false;
- sound3Set = false;
- sound4Set = false;
- sound5Set = false;
- sound6Set = false;
-
- gSACurControl = playButton1;
- SetMyTitle ("\pLoad Sound 1");
- gSACurControl = playButton2;
- SetMyTitle ("\pLoad Sound 2");
- gSACurControl = playButton3;
- SetMyTitle ("\pLoad Sound 3");
- gSACurControl = playButton4;
- SetMyTitle ("\pLoad Sound 4");
- gSACurControl = playButton5;
- SetMyTitle ("\pLoad Sound 5");
- gSACurControl = playButton6;
- SetMyTitle ("\pLoad Sound 6");
-
- return err;
- }
-
- /*-----------------------------------------------------------------------*/
- void main (void)
- /*-----------------------------------------------------------------------*/
- {
- Rect r;
- long soundAttr;
- short err;
-
- InitSimpleApp (2, kUseStandardMenu); /* Simple App Sets up the Tool Box For us */
- GetDocumentWindow (128); /* Get our stored window */
-
- SetRectLocation (&r, 10, 2); /* This Sets a rects anchor point */
- SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- {
- long buttonID = 1;
- err = InstallPushButton (&buttonID, gSACurrentWindow, "\pLoad Sound 1", &r, (char)0, (ButtonHitProc) DoPlay1, (ButtonUpdateProc)nil);
- playButton1 = gSACurControl;
- }
-
- SetRectLocation (&r, 130, 2); /* This Sets a rects anchor point */
- SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- {
- long buttonID = 2;
- err = InstallPushButton (&buttonID, gSACurrentWindow, "\pLoad Sound 2", &r, (char)0, (ButtonHitProc) DoPlay2, (ButtonUpdateProc)nil);
- playButton2 = gSACurControl;
- }
-
- SetRectLocation (&r, 270, 2); /* This Sets a rects anchor point */
- SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- {
- long buttonID = 3;
- err = InstallPushButton (&buttonID, gSACurrentWindow, "\pLoad Sound 3", &r, (char)0, (ButtonHitProc) DoPlay3, (ButtonUpdateProc)nil);
- playButton3 = gSACurControl;
- }
-
- SetRectLocation (&r, 10, 25); /* This Sets a rects anchor point */
- SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- {
- long buttonID = 4;
- err = InstallPushButton (&buttonID, gSACurrentWindow, "\pLoad Sound 4", &r, (char)0, (ButtonHitProc) DoPlay4, (ButtonUpdateProc)nil);
- playButton4 = gSACurControl;
- }
-
- SetRectLocation (&r, 130, 25); /* This Sets a rects anchor point */
- SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- {
- long buttonID = 5;
- err = InstallPushButton (&buttonID, gSACurrentWindow, "\pLoad Sound 5", &r, (char)0, (ButtonHitProc) DoPlay5, (ButtonUpdateProc)nil);
- playButton5 = gSACurControl;
- }
-
- SetRectLocation (&r, 270, 25); /* This Sets a rects anchor point */
- SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- {
- long buttonID = 6;
- err = InstallPushButton (&buttonID, gSACurrentWindow, "\pLoad Sound 6", &r, (char)0, (ButtonHitProc) DoPlay6, (ButtonUpdateProc)nil);
- playButton6 = gSACurControl;
- }
-
- SetRectLocation (&r, 10, 50); /* This Sets a rects anchor point */
- SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- {
- long buttonID = 7;
- err = InstallPushButton (&buttonID, gSACurrentWindow, "\pSetup Rec", &r, (char)0, (ButtonHitProc) DoRecord, (ButtonUpdateProc)nil);
- recordButton = gSACurControl;
- }
-
- SetRectLocation (&r, 110, 80); /* This Sets a rects anchor point */
- SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- {
- long buttonID = 8;
- err = InstallPushButton (&buttonID, gSACurrentWindow, "\pPlay All", &r, (char)0, (ButtonHitProc) DoPlayAll, (ButtonUpdateProc)nil);
- playAllButton = gSACurControl;
- }
-
- SetRectLocation (&r, 110, 2); /* This Sets a rects anchor point */
- SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- {
- long buttonID = 9;
- err = InstallCheckBox (&buttonID, gSACurrentWindow, "\p", &r , (char)0, 1, (ButtonHitProc) MuteSound1, (ButtonUpdateProc)nil);
- muteCheck1 = gSACurControl;
- }
-
- SetRectLocation (&r, 250, 2); /* This Sets a rects anchor point */
- SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- {
- long buttonID = 10;
- err = InstallCheckBox (&buttonID, gSACurrentWindow, "\p", &r , (char)0, 1, (ButtonHitProc) MuteSound2, (ButtonUpdateProc)nil);
- muteCheck2 = gSACurControl;
- }
-
- SetRectLocation (&r, 370, 2); /* This Sets a rects anchor point */
- SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- {
- long buttonID = 11;
- err = InstallCheckBox (&buttonID, gSACurrentWindow, "\p", &r , (char)0, 1, (ButtonHitProc) MuteSound3, (ButtonUpdateProc)nil);
- muteCheck3 = gSACurControl;
- }
-
- SetRectLocation (&r, 110, 25); /* This Sets a rects anchor point */
- SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- {
- long buttonID = 12;
- err = InstallCheckBox (&buttonID, gSACurrentWindow, "\p", &r , (char)0, 1, (ButtonHitProc) MuteSound4, (ButtonUpdateProc)nil);
- muteCheck4 = gSACurControl;
- }
-
- SetRectLocation (&r, 250, 25); /* This Sets a rects anchor point */
- SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- {
- long buttonID = 13;
- err = InstallCheckBox (&buttonID, gSACurrentWindow, "\p", &r , (char)0, 1, (ButtonHitProc) MuteSound5, (ButtonUpdateProc)nil);
- muteCheck5 = gSACurControl;
- }
-
- SetRectLocation (&r, 370, 25); /* This Sets a rects anchor point */
- SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- {
- long buttonID = 14;
- err = InstallCheckBox (&buttonID, gSACurrentWindow, "\p", &r , (char)0, 1, (ButtonHitProc) MuteSound6, (ButtonUpdateProc)nil);
- muteCheck6 = gSACurControl;
- }
-
- mySoundInfo1 = ASoundNew (&err);
- if (err == noErr)
- mySoundInfo2 = ASoundNew (&err);
- if (err == noErr)
- mySoundInfo3 = ASoundNew (&err);
- if (err == noErr)
- mySoundInfo4 = ASoundNew (&err);
- if (err == noErr)
- mySoundInfo5 = ASoundNew (&err);
- if (err == noErr)
- mySoundInfo6 = ASoundNew (&err);
-
- InstallMenuItem (130, 9, "\pClear all sounds", 0, 'R', ClearAllSounds, nil);
- InstallIdleProc ((EventProcs)MyIdleProc);
-
- err = Gestalt (gestaltSoundAttr, &soundAttr);
- if ((soundAttr & (1 << gestaltPlayAndRecord)) == false) {
- DebugStr ("\pCan't play and record simultaniously.");
- }
-
- if (err == noErr)
- Run (); /* Let SimpleApp handle the rest */
- }
-
- // utility functions since I already keep the control handle around
- /*-----------------------------------------------------------------------*/
- void EnableControl (ControlRef cr)
- /*-----------------------------------------------------------------------*/
- {
- if (cr != nil) {
- HiliteControl(cr, nil);
- }
- }
-
- /*-----------------------------------------------------------------------*/
- void DisableControl (ControlRef cr)
- /*-----------------------------------------------------------------------*/
- {
- if (cr != nil) {
- HiliteControl(cr, 255);
- }
- }
-